<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议  https://mit-license.org 
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\model\api;

use laytp\BaseModel;
use think\model\concern\SoftDelete;

class SkyStrategy extends BaseModel
{
    protected $name = 'sky_strategy';


    /**
     * 季节详情
     * @param $season
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail($season){
        $detail = $this->where('season','=',$season)->cache(true)->find()->toArray();

        $task_list = [];
        for($i=1;$i<=8;$i++){
            $content = json_decode($detail['content'.$i],true);
            if(!empty($content)){
                $task_list[] = array(
                    'id' => $i,
                    'index' => $detail['index'.$i],
                    'title' => $detail['title'.$i],
                    'img' => $content
                );
            }
        }

        $return = array(
            'name' => $season,
            'navBarTitle'        => $detail['navBarTitle'],
            'taskIndexTitle'     => $detail['taskIndexTitle'],
            'richTextContent'    => $detail['description'],
            'taskIndex'          => $task_list,
        );
        return $return;
    }
}